<template>
	<!-- 修改登录密码 -->
	<view class="edit">
		<view class="editPass flex">
			<text>当前密码</text>
			<input type="password" placeholder="请输入当前登录密码" v-model="curPasswrod"/>
		</view>
		<view class="editPass flex">
			<text>新登录密码</text>
			<input type="password" placeholder="请输入6-18的密码" v-model="newPassword"/>
		</view>
		<view class="editPass flex">
			<text>确认新密码</text>
			<input type="password" placeholder="请再次输入一次新登录密码" v-model="rePasswrod"/>
		</view>
		<view class="editBtn flex-c" @click="fnEditPassword()">
			<text>确认修改</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				curPasswrod:'',
				newPassword:'',
				rePasswrod:'',
				token:uni.getStorageSync('token')
			};
		},
		methods:{
			fnEditPassword(){
				if(!this.curPasswrod) return uni.showToast({
					title:'请输入当前登录密码',
					icon:'none'
				})
				if(!this.newPassword) return uni.showToast({
					title:'请输入6-18的密码',
					icon:'none'
				})
				if(!this.rePasswrod || this.rePasswrod != this.newPassword) return uni.showToast({
					title:'请再次输入正确的新登录密码',
					icon:'none'
				})
				this.request({
					url: '/czb/user/userSetPassword',
					method: 'POST',
					data: {
						'store_id': 1,
						'token':this.token,
						'old_password':this.curPasswrod,
						'new_password':this.newPassword,
						'confirm_new_password':this.rePasswrod
					},
				}).then((ret) => {
					console.log(ret);
					if (ret.code == 0) { 
						uni.showToast({
							title:ret.message,
							icon:'success'
						})
						setTimeout(function(){
							uni.navigateBack()
						},1500)
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page{
		padding: 30rpx 0;
	}
	.edit{
		
		.editPass{
			height: 120rpx;
			background: #fff;
			padding: 0 20rpx;
			font-size: 28rpx;
			margin-bottom: 30rpx;
			align-items: center;
			text{
				flex: 1;
				font-size: 30rpx;
			}
			input{
				flex: 2.5;
			}
		}
		.editBtn{
			width: 710rpx;
			height: 90rpx;
			border-radius: 20rpx;
			background: linear-gradient(270deg, #F22F29, #FC6655);
			margin: 60rpx auto;
			color: #fff;
			font-size: 30rpx;
		}
	}
	
</style>
